<template>
	<view class="content">
		<People :details="details"></People>
		<view class="main">
			<view class="idea">
				<view class="ideaTitle">
					<text>求职意向</text>
				</view>
				<text class="ideaLeft">岗位：<text class="ideaRight">{{details.resumeIntention}}</text></text>
				<text class="ideaLeft">职位类型：<text class="ideaRight">{{details.resumeEmail}}</text></text>
				<text class="ideaLeft" v-if="0">工作性质：<text class="ideaRight">实践/学习/就业</text></text>
			</view>
			<view class="education">
				<view class="educationTitle">
					<text>教育经历</text>
				</view>
				<text class="educationSchool" v-if="0">{{details.txtUniversity}}：<text class="educationTime"
						v-if="0">2018.07 -
						2020.07</text></text>
				<text class="educationJob">{{details.educationExperience}}</text>
			</view>
			<view class="work">
				<view class="workTitle">
					<text>工作经历</text>
				</view>
				<text class="workTime" v-if="0">2018.07 - 2020.07</text>
				<text class="workBox" v-if="0">实习生<text class="workName" v-if="0">某某公司</text></text>
				<text class="workBox">{{details.resumeProject}}</text>
			</view>
			<view class="prize">
				<view class="prizeTitle">
					<text>获奖经历</text>
				</view>
				<text class="prize1">{{details.awardExperience}}</text>
				<text class="prize2" v-if="0">2017.08 获得大学生奥数竞赛一等奖</text>
			</view>
			<view class="myself">
				<view class="myselfTitle">
					<text>自我介绍</text>
				</view>
				<text class="datas">{{details.resumeDesc}}</text>
			</view>
			<view class="invitation">
				<view class="heart" @click="positionAdds(isPosition)">
					<image
						:src="isPosition===0?'/static/employInformation/heart.png':'/static/employInformation/heartSelected.png'"
						mode=""></image>
					<text>收藏</text>
				</view>
				<view class="buttom" @tap="tapPosPopup">
					<button type="default">立即邀约</button>
				</view>
			</view>
		</view>
		<Tabbar :current="0"></Tabbar>
	</view>
</template>

<script>
	import People from "./components/People"
	import Tabbar from "@/components/Tabbar/Tabbar"
	import {
		isResumeFavorite,
		positionAdd,
		resumeCancel
	} from '@/api/isBool'
	import dictType from '@/mixins/dictType-minxis'
	import {
		emResumeInfo
	} from '@/api/home'
	import {
		isLogins
	} from '@/utils/isLogin'
	export default {
		mixins: [dictType],
		components: {
			People,
			Tabbar
		},
		onShow() {
			uni.hideTabBar({
				animation: false
			})
		},
		data() {
			return {
				details: {}, //详情数据
				isPosition: 0, //是否收藏
			}
		},
		onLoad({
			id
		}) {
			this.id = id
			this.isResumeFavorite(this.id)
			this.emResumeInfo(id)
      this.comRest()
		},
		methods: {
      comRest(){
        this.onReset()
      },
			// 弹窗
			tapPosPopup() {
        this.$navigateTo(`/pages/inviteInterview/inviteInterview?resumeId=${this.id}&resumeName=${this.details.resumeName}`)
			},
			//简历添加
			positionAdd() {
				positionAdd({
					resumeId: this.id
				}).then(res => {
					const {
						code,
						message
					} = res
					if (code === 200) {
						this.$showToast(message)
						this.emResumeInfo(this.id)
						this.isResumeFavorite(this.id)

					} else {
						this.$showToast(message)
					}
				}).catch(e => {
					this.$showToast(e.message)
				})
			},
			//添加职位
			positionAdds(isPosition) {
				const {
					token
				} = this.$store.state
				if (!token) {
					isLogins()
					return
				}
				if (isPosition === 0) {
					this.$showLoading({
						title: '收藏中...'
					})
					this.positionAdd()
				} else {
					this.$showLoading({
						title: '取消中...'
					})
					this.resumeCancel()
				}
			},
			//简历取消
			resumeCancel() {
				resumeCancel({
					resumeId: this.id
				}).then(res => {
					const {
						code,
						message
					} = res
					this.$hideLoading()
					if (code === 200) {
						this.$showToast(message)
						this.isResumeFavorite(this.id)
						this.emResumeInfo(this.id)
					} else {
						this.$showToast(message)
					}
				}).catch(e => {
					this.$hideLoading()
					this.$showToast(e.message)
				})
			},
			//简历是否被我收藏
			isResumeFavorite(resumeId) {
				isResumeFavorite({
					resumeId
				}).then(res => {
					const {
						code,
						result
					} = res
					this.$hideLoading()
					if (code === 200) {
						this.isPosition = result
					}
				}).catch(e => {
					this.$hideLoading()
				})
			},
			//简历-通过id查询
			emResumeInfo(a) {
        emResumeInfo(a).then(res => {
					const {
						code,
						result
					} = res
					if (code === 200) {
						this.details = result
          }
				}).catch(e => {
					console.log(e)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		.main {
			padding-bottom: 120rpx;
			background: #F7F9FA;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;


			.idea {
				padding: 30rpx;
				background: #FFFFFF;
				color: #969799;

				.ideaTitle {
					margin-bottom: 20rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #323233;
				}

				.ideaLeft {
					margin-top: 10rpx;
					display: block;
				}

				.ideaRight {
					margin-left: 20rpx;
					color: #323233;
				}
			}

			.education {
				margin-top: 20rpx;
				padding: 30rpx;
				background: #FFFFFF;

				.educationTitle {
					margin-bottom: 20rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #323233;
				}

				.educationSchool {
					margin-top: 10rpx;
					display: block;

					.educationTime {
						margin-left: 40rpx;
					}
				}

				.educationJob {
					margin-top: 10rpx;
					display: block;
					color: #969799;
				}
			}

			.work {
				margin-top: 20rpx;
				padding: 30rpx;
				background: #FFFFFF;

				.workTitle {
					margin-bottom: 20rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #323233;
				}

				.workBox {
					margin-top: 10rpx;
					display: block;
				}

				.workName {
					margin-left: 50rpx;
				}
			}

			.prize {
				margin-top: 20rpx;
				padding: 30rpx;
				background: #FFFFFF;

				.prizeTitle {
					margin-bottom: 20rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #323233;
				}

				.prize1 {
					margin: 10rpx 0;
					display: block;
				}
			}

			.myself {
				margin-top: 20rpx;
				padding: 30rpx;
				background: #FFFFFF;
        margin-bottom: 100rpx;
				.myselfTitle {
					margin-bottom: 20rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #323233;
				}
			}

			.invitation {
				margin-top: 10rpx;
				padding: 0 20rpx;
				height: 100rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				background: #FFFFFF;
        position: fixed;
        bottom: 100rpx;
        left: 0;
        width: 100%;
				.heart {
					margin-left: 20rpx;
					display: flex;
					flex-direction: column;
					align-items: center;

					image {
						width: 50rpx;
						height: 50rpx;
					}

					text {
						font-size: 24rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #AFB1B3;
					}
				}

				.buttom {
					button {
						width: 530rpx;
						height: 78rpx;
						line-height: 78rpx;
						color: #FFFFFF;
						background: #F27A2B;
					}
				}
			}
		}
	}
  .datas{
    word-break: break-all;
  }
</style>
